package flexulous.view;

/*
 * FlexulousOptionPane.java
 * part of the Flexulous plugin for the jEdit text editor
 * Copyright (C) 2001 Chris Hill
 * jgellene@nyc.rr.com
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 * $Id: FlexulousOptionPane.java 12504 2008-04-22 23:12:43Z ezust $
 */

import java.awt.BorderLayout;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JFileChooser;
import javax.swing.JPanel;
import javax.swing.*;

import org.gjt.sp.jedit.AbstractOptionPane;
import org.gjt.sp.jedit.GUIUtilities;
import org.gjt.sp.jedit.jEdit;
import org.gjt.sp.jedit.gui.FontSelector;
import org.gjt.sp.jedit.browser.VFSBrowser;

import flexulous.FlexulousPlugin;

public class FlexulousOptionPane extends AbstractOptionPane {
	private JTextField sdkPathName;
	private JTextField growlPathName;

	public FlexulousOptionPane() {
		super(FlexulousPlugin.NAME);
	}

	public void _init() {
		sdkPathName = new JTextField(jEdit
				.getProperty(FlexulousPlugin.OPTION_PREFIX + "sdklocation"));
		JButton pickSdkPath = new JButton(jEdit
				.getProperty(FlexulousPlugin.OPTION_PREFIX + "choose-sdk"));
		pickSdkPath.addActionListener(new ActionListener(){
				// begin ActionListener implementation
				public void actionPerformed(ActionEvent evt) {
					String[] paths = GUIUtilities.showVFSFileDialog(jEdit.getActiveView(), null,
							 VFSBrowser.CHOOSE_DIRECTORY_DIALOG, false);
					if (paths != null) {
						sdkPathName.setText(paths[0]);
					}
				}
		});

		JPanel pathSdkPanel = new JPanel(new BorderLayout(0, 0));
		pathSdkPanel.add(sdkPathName, BorderLayout.CENTER);
		pathSdkPanel.add(pickSdkPath, BorderLayout.EAST);

		addComponent(jEdit.getProperty(FlexulousPlugin.OPTION_PREFIX
				+ "choose-sdk"), pathSdkPanel);

		growlPathName = new JTextField(jEdit
				.getProperty(FlexulousPlugin.OPTION_PREFIX + "growllocation"));
		JButton pickGrowlPath = new JButton(jEdit
				.getProperty(FlexulousPlugin.OPTION_PREFIX + "choose-growl"));
		pickGrowlPath.addActionListener(new ActionListener(){
				// begin ActionListener implementation
				public void actionPerformed(ActionEvent evt) {
					String[] paths = GUIUtilities.showVFSFileDialog(jEdit.getActiveView(), null,
							 VFSBrowser.OPEN_DIALOG, false);
					if (paths != null) {
						growlPathName.setText(paths[0]);
					}
				}
		});

		JPanel pathGrowlPanel = new JPanel(new BorderLayout(0, 0));
		pathGrowlPanel.add(growlPathName, BorderLayout.CENTER);
		pathGrowlPanel.add(pickGrowlPath, BorderLayout.EAST);

		JLabel sdkRestartInfo = new JLabel(jEdit
				.getProperty(FlexulousPlugin.OPTION_PREFIX + "sdkrestartinfo"));
		addComponent(sdkRestartInfo);
		addComponent(jEdit.getProperty(FlexulousPlugin.OPTION_PREFIX
				+ "choose-growl"), pathGrowlPanel);

	}

	public void _save() {
		jEdit.setProperty(FlexulousPlugin.OPTION_PREFIX + "sdklocation",
				sdkPathName.getText());
		
		jEdit.setProperty(FlexulousPlugin.OPTION_PREFIX + "growllocation",
				growlPathName.getText());
		FlexulousPlugin.getModel().setGrowlLocation(growlPathName.getText());
		
	}

	// end AbstractOptionPane implementation




}
